package com.loveedu.apih5.user;

import com.alibaba.fastjson.JSONObject;
import com.loveedu.apib.user.dto.Pager;
import com.loveedu.frame.annotation.CurrentUser;
import com.loveedu.frame.annotation.LoginRequired;
import com.loveedu.models.Supplier;
import com.loveedu.models.SysUser;
import com.loveedu.services.user.SupplierService;
import com.loveedu.utils.PageBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 供应商信息
 *
 */
@RestController
@RequestMapping({"/supplier"})
public class SupplierController {
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private SupplierService supplierService;

//    @Autowired
//    private SysUserService sysUserServices;
//
//    @ResponseBody
//    @RequestMapping(value = "/registeredUser")
//    public Object registeredUser(String userName, String realName, String cellphone, String emodelId, String password, String email, String description) {
//        logger.info("registeredUser:userName:" + userName + ",realName:" + realName + ",cellphone:" + cellphone + ",emodelId:" + emodelId + ",password" + password + ",email" + email + ",description:" + description);
//        JSONObject jsonObject = sysUserServices.registeredUser(userName, realName, cellphone, emodelId, password, email, description);
//        return jsonObject;
//    }
//
//    @LoginRequired
//    @ResponseBody
//    @RequestMapping(value = "/modifyUserPassword")
//    public Object modifyUserPassword(String userId, String oldPassword, String newPassword) {
//        JSONObject jsonObject = sysUserServices.modifyUserPassword(userId, oldPassword, newPassword);
//        return jsonObject;
//    }
//
//
//    @LoginRequired
//    @ResponseBody
//    @RequestMapping(value = "/modifyUserInfo")
//    public Object modifyUserInfo(@CurrentUser SysUser user, String userId, String userName, String realName, String cellphone, String emodelId,
//                                 @RequestParam(value = "email", required = false) String email,
//                                 @RequestParam(value = "description", required = false) String description) {
//        logger.info(user.getUserName());
//        logger.info("registeredUser:userId:" + userId + ",userName:" + userName + ",realName:" + realName + ",cellphone:" + cellphone + ",emodelId:" + emodelId + ",email" + email + ",description:" + description);
//        JSONObject jsonObject = sysUserServices.modifyUserInfo(userId, userName, realName, cellphone, emodelId, email, description);
//        return jsonObject;
//    }
//
//    @LoginRequired
//    @ResponseBody
//    @RequestMapping(value = "/resetUserPassword")
//    public Object resetUserPassword(String userId, String newPassword) {
//        JSONObject jsonObject = sysUserServices.resetUserPassword(userId, newPassword);
//        return jsonObject;
//    }

    /**
     * 添加供应商
     * @param supplier
     * @return
     */
    @ResponseBody
    @PostMapping(value = "/add")
    public Object addSupplier(Supplier supplier) {
        return supplierService.add(supplier);
    }

    /**
     * 添加供应商
     * @param supplier
     * @return
     */
    @ResponseBody
    @GetMapping(value = "/list")
    public Object listSupplier(Supplier supplier, Pager pager) {
        return supplierService.list(supplier,pager);
    }
}


